<%@ Page Language="VB" MasterPageFile="~/Admin/Admin.master" AutoEventWireup="false" CodeFile="FormPermissions.aspx.vb" Inherits="Admin_FormPermissions" title="Admin - Edit Field Permissions" %>
<%@ Register Src="SubNavControls/FieldsSubNavControl.ascx" TagName="FieldsSubNavControl" TagPrefix="uc1" %>
<%@ Register Assembly="InputControls" Namespace="InputControls" TagPrefix="cc2" %>

<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder2" Runat="Server">
    <uc1:FieldsSubNavControl ID="SubNavCtrl" runat="server" />
<asp:ObjectDataSource ID="FormPermissionsObjectDataSource" runat="server" SelectMethod="ListRequiredFieldTables"
            TypeName="Cdm.DataCore.LookupTables.LUAdminTableList" DataObjectTypeName="Cdm.DataCore.LookupTables.LUAdminTableList">
        </asp:ObjectDataSource>

        <asp:ObjectDataSource ID="RolesObjectDataSource" runat="server" SelectMethod="ListActive"
            TypeName="Cdm.DataCore.UserSecurity.Role" DataObjectTypeName="Cdm.DataCore.UserSecurity.Role" UpdateMethod="UpdateInstance" InsertMethod="ListAll">
        </asp:ObjectDataSource>
        
    <asp:ObjectDataSource ID="FormFieldsObjectDataSource" runat="server" DataObjectTypeName="Cdm.DataCore.Admin.AdminFieldLevelPermission" DeleteMethod="RemoveInstance" InsertMethod="SaveInstance" SelectMethod="ListByRoleXTable"
        TypeName="Cdm.DataCore.Admin.AdminFieldLevelPermission" UpdateMethod="UpdateInstance" SortParameterName="sortExpr">
            <SelectParameters>
                <asp:ControlParameter ControlID="RolesDropDownList" PropertyName="SelectedValue" Name="roleId" Type="Int32" />
                <asp:ControlParameter ControlID="FormPermissionsDropDownList" PropertyName="SelectedValue" Name="tableId" Type="Int32" />
            </SelectParameters>
    </asp:ObjectDataSource>    

<table cellpadding="0" cellspacing="0" style="width:920px;">
<tr><td style="width:20px;" rowspan="5"></td>
<td colspan="2"><h1><a id="pagecontent">Admin - Edit Field Permissions</a></h1></td></tr>
    <tr><td style="width:450px" align="left"><asp:Label ID="FileLabel" runat="server" AssociatedControlID="FormPermissionsDropDownList" Text="Select File:" CssClass="adminSelectLabel"></asp:Label>
    <asp:DropDownList ID="FormPermissionsDropDownList" runat="server" CssClass="adminSelectForm" DataSourceID="FormPermissionsObjectDataSource" DataTextField="DisplayName" DataValueField="TableId" AutoPostBack="false">
    </asp:DropDownList>
    <asp:Button ID="SubmitFormButton" runat="server" Text="Go" />
    </td>
    <td style="width:450px;" align="right"><asp:Label ID="RoleLabel" runat="server" AssociatedControlID="RolesDropDownList" Text="Select Role:" CssClass="adminSelectLabel"></asp:Label>
    <asp:DropDownList ID="RolesDropDownList" runat="server" CssClass="adminSelectForm" DataSourceID="RolesObjectDataSource" DataTextField="RoleDisplayName" DataValueField="RoleId" AutoPostBack="false">
    </asp:DropDownList>
    <asp:Button ID="SubmitRolesButton" runat="server" Text="Go" />
    </td>
    </tr>
    <tr style="height:10px">
    <td colspan="2" align="center"></td></tr>
    <tr>
    <td colspan="2" align="center">
    <cc2:ScrollingGridView ID="FormPermissionsScrollingGridView" runat="server" CssClass="gridOffsetSmall" IsFixedColumn="true" AutoGenerateColumns="False" Caption="Select which fields each role will be allowed to edit." CaptionAlign="Top" ToolTip="170"
            DataSourceID="FormFieldsObjectDataSource" DataKeyNames="RoleId,RequiredFieldID,TableID" CellPadding="5" BorderColor="#21334B" 
                BorderStyle="Solid" GridLines="Vertical" EmptyDataText="No data for this table and role." AllowSorting="true">
        <HeaderStyle  CssClass="adminHeaderStyle" BackColor="#C3CAD4" BorderColor="#21334B" VerticalAlign="Top" />
        <RowStyle CssClass="adminColumnStyle" />
        <Columns>
            <asp:TemplateField HeaderText="Field Name" SortExpression="fieldName">
            <ItemStyle Width="500px" />
            <HeaderStyle Width="506px" />
            <ItemTemplate><%#Eval("FieldDisplayName")%></ItemTemplate>
            </asp:TemplateField>
            <asp:TemplateField HeaderText="Editable">
            <ItemStyle Width="300px" HorizontalAlign="center" />
            <HeaderStyle Width="340px" />
            <ItemTemplate>
            <asp:CheckBox ID="IsEditableCheckBox" runat="server" Checked='<%#Eval("IsEditable")%>' ToolTip="Check if selected role may edit." />
            </ItemTemplate>
            </asp:TemplateField>
        </Columns>
        <AlternatingRowStyle BackColor="#E8ECF4" />
        <EmptyDataRowStyle CssClass="headerStyle" BackColor="#C3CAD4" /></cc2:ScrollingGridView>
 </td>
    </tr>
    </table>

</asp:Content>
<asp:Content ID="FixedContent" runat="server" ContentPlaceHolderID="ContentPlaceHolderFixedAdmin">
    <asp:Button ID="SaveButton" runat="server" Text="Save" />
</asp:Content>

